import cv2
import numpy


def get_border(image_name, left):
    img = cv2.imread(image_name, 2)  # 读取图像
    target = cv2.Canny(img, 1, 1)  # 提取边界
    border_y, border_x = numpy.where(target > 0)
    border_y = border_y if left else target.shape[0] - border_y
    return border_x, border_y, img.shape[1], img.shape[0]
